<?php 
namespace app\admin\validate;
use app\admin\code\AdminCode;
use app\admin\code\AuthCode;
use app\admin\code\BaseCode;
use app\admin\model\BaseModel;
use think\Validate;

class CategoryValidate extends BaseValidate
{
    protected $_rule = [
        'id'       =>  'require',
        'name'     =>  'require',
        'sort'     =>  'number',
        'logo'     =>  'require',
        'is_index' =>  'in:0,1',
    ];
    protected $_field = [
        'id'=>'类目',
        'name'=>'类目名字',
        'sort'=>'排序',
        'logo'=>'类目图标',
        'is_index'=>'是否显示在首页',
    ];
    protected $_message = [
        'id.require' => BaseCode::PARAM_CANT_EMPTY,
        'name.require' => BaseCode::PARAM_CANT_EMPTY,
        'sort.number' => BaseCode::PARAM_MUST_NUMBER,
        'is_index.in' => BaseCode::PARAM_MUST_IN,
        'logo.require' => BaseCode::PARAM_CANT_EMPTY,
    ];
    protected $_scene = [
        'update' => ['id','name','logo','is_index','sort'],
        'add'    => ['name','logo','is_index','sort'],
        'del' => ['id'],
    ];
}


